<template>
  <div class="cu-common-layout">
    <div class="cu-common-layout-center">
      <el-row class="cu-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="4">
            <el-form-item label="管理区域" prop="areaCode">
              <el-select v-model="query.areaCode" placeholder="请选择管理区域" clearable>
                <el-option :key="item.enCode" :label="item.fullName" :value="item.enCode" v-for="item in areaOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="省份" prop="provinceId">
              <el-select v-model="query.provinceId" placeholder="请选择省份" clearable @change="handleProvinceChange">
                <el-option :key="item.id" :label="item.fullName" :value="item.id" v-for="item in provinceOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="城市" prop="cityId">
              <el-select v-model="query.cityId" placeholder="请选择城市" clearable>
                <el-option :key="item.id" :label="item.fullName" :value="item.id" v-for="item in cityOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="状态" prop="enabledMark">
              <el-select v-model="query.enabledMark" placeholder="请选择状态" clearable>
                <el-option label="启用" :value="1" />
                <el-option label="禁用" :value="0" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()" native-type="submit">{{ $t('common.search') }}</el-button>
              <el-button icon="el-icon-refresh-right" @click="reset()">{{ $t('common.reset') }}</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="cu-common-layout-main cu-flex-main">
        <div class="cu-common-head">
          <div>
            <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()" v-has="'btn_add'">新增</el-button>
            <el-button type="text" icon="el-icon-delete" @click="handleBatchRemoveDel()" v-has="'btn_batchRemove'">批量删除</el-button>
          </div>
          <div class="cu-common-head-right">
            <el-tooltip effect="dark" content="刷新" placement="top">
              <el-link icon="icon-ym icon-ym-Refresh cu-common-head-icon" :underline="false" @click="reset()" />
            </el-tooltip>
            <screenfull isContainer />
          </div>
        </div>
        <custom-table v-loading="listLoading" :data="list" has-c @selection-change="handleSelectionChange">
          <el-table-column prop="areaName" label="管理区域" align="left" width="120" show-overflow-tooltip />
          <el-table-column prop="provinceName" label="省份" align="left" width="100" show-overflow-tooltip />
          <el-table-column prop="cityName" label="城市" align="left" width="100" show-overflow-tooltip>
            <template slot-scope="scope">
              <span v-if="scope.row.cityName">{{ scope.row.cityName }}</span>
              <span v-else style="color: #999;">整个省份</span>
            </template>
          </el-table-column>
          <el-table-column prop="priority" label="优先级" align="center" width="80" />
          <el-table-column prop="enabledMark" label="状态" align="center" width="80">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.enabledMark == 1" key="启用" type="success" effect="dark">
                启用
              </el-tag>
              <el-tag v-else key="禁用" type="danger" effect="dark">
                禁用
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="description" label="描述" align="left" width="200" show-overflow-tooltip />
          <el-table-column prop="createTime" label="创建时间" align="center" :formatter="custom.tableDateTimeFormat" width="140" />
          <el-table-column prop="createUserName" label="创建用户" align="left" width="100" show-overflow-tooltip />
          <el-table-column prop="updateTime" label="修改时间" align="center" :formatter="custom.tableDateTimeFormat" width="140" />
          <el-table-column prop="updateUserName" label="修改用户" align="left" width="100" show-overflow-tooltip />
          <el-table-column label="操作" fixed="right" width="150" align="center">
            <template slot-scope="scope">
              <el-button type="text" size="mini" @click="addOrUpdateHandle(scope.row.id)" v-has="'btn_edit'">编辑</el-button>
              <el-button type="text" size="mini" @click="handleToggleStatus(scope.row)" v-has="'btn_edit'">
                {{ scope.row.enabledMark == 1 ? '禁用' : '启用' }}
              </el-button>
              <el-button type="text" size="mini" @click="handleDel(scope.row.id)" class="cu-table-delBtn" v-has="'btn_remove'">删除</el-button>
            </template>
          </el-table-column>
        </custom-table>
        <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
      </div>
    </div>
    <custom-form v-if="formVisible" ref="CustomForm" @refresh="search" />
  </div>
</template>
<script>
export { default } from './index.js'
</script>
<style lang="scss" scoped>
@import url(index.scss);
</style>